import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      meta: {
        title: '首页',
        keepAlive: true //需要缓存
      },
      component: resolve => {
        require(['../views/index.vue'], resolve)
      },
      // redirect: to => {
      //   return '/index'
      // }
    },
    {
      path: '/news',
      name: 'news',
      meta: {
        title: '消息',
        keepAlive: true //需要缓存
      },
      component: resolve => {
        require(['../views/news.vue'], resolve)
      },
    },
    {
      path: '/mine',
      name: 'mine',
      meta: {
        title: '我的',
        keepAlive: true //需要缓存
      },
      component: resolve => {
        require(['../views/mine.vue'], resolve)
      },
    },
    {
      path: '/newsInfo',
      name: 'newsInfo',
      meta: {
        title: '消息详情',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/newsInfo.vue'], resolve)
      },
    },
    {
      path: '/userInfo',
      name: 'userInfo',
      meta: {
        title: '用户详情',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/userInfo.vue'], resolve)
      },
    },
    {
      path: '/registerNum',
      name: 'registerNum',
      meta: {
        title: '注册编号',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/registerNum.vue'], resolve)
      },
    },
    {
      path: '/coachIntro',
      name: 'coachIntro',
      meta: {
        title: '私教简介',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/coachIntro.vue'], resolve)
      },
    },
    {
      path: '/certificate',
      name: 'certificate',
      meta: {
        title: '专业证书',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/certificate.vue'], resolve)
      },
    },
    {
      path: '/certificateAdd',
      name: 'certificateAdd',
      meta: {
        title: '添加证书',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/certificateAdd.vue'], resolve)
      },
    },
    {
      path: '/competieResults',
      name: 'competieResults',
      meta: {
        title: '赛事成绩',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/competieResults.vue'], resolve)
      },
    },
    {
      path: '/competieResultsAdd',
      name: 'competieResultsAdd',
      meta: {
        title: '赛事成绩添加',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/competieResultsAdd.vue'], resolve)
      },
    },
    {
      path: '/rests',
      name: 'rests',
      meta: {
        title: '其他',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/rests.vue'], resolve)
      },
    },
    {
      path: '/restsAdd',
      name: 'restsAdd',
      meta: {
        title: '添加其他',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/restsAdd.vue'], resolve)
      },
    },
    {
      path: '/myInformation',
      name: 'myInformation',
      meta: {
        title: '我的信息',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/myInformation.vue'], resolve)
      },
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        title: '登录',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/login.vue'], resolve)
      },
    },
    {
      path: '/signIn',
      name: 'signIn',
      meta: {
        title: '注册',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/signIn.vue'], resolve)
      },
    },
     {
      path: '/search',
      name: 'search',
      meta: {
        title: '搜索',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/search.vue'], resolve)
      },
    },

  ]
})